Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serialport/parser-delimiter

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serialport/parser-delimiter

See our api docs https://serialport.io/docs/api-parser-delimiter

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
128K
decreased by-2.02%
Maintainers
1
Weekly downloads
 
Created

What is @serialport/parser-delimiter?

@serialport/parser-delimiter is a parser for the serialport library that allows you to split data into chunks based on a specified delimiter. This is particularly useful for processing data streams where messages are separated by a specific character or sequence of characters.

What are @serialport/parser-delimiter's main functionalities?

Basic Usage

This code demonstrates how to set up a basic serial port connection and use the delimiter parser to split incoming data based on newline characters.

const SerialPort = require('serialport');
const Delimiter = require('@serialport/parser-delimiter');

const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Delimiter({ delimiter: '\n' }));

parser.on('data', data => {
  console.log('Received data:', data.toString());
});

Custom Delimiter

This example shows how to use a custom delimiter (in this case, a carriage return followed by a line feed) to split incoming data.

const SerialPort = require('serialport');
const Delimiter = require('@serialport/parser-delimiter');

const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Delimiter({ delimiter: Buffer.from([0x0D, 0x0A]) })); // Carriage return and line feed

parser.on('data', data => {
  console.log('Received data:', data.toString());
});

Handling Binary Data

This example demonstrates how to handle binary data streams by using a custom binary delimiter.

const SerialPort = require('serialport');
const Delimiter = require('@serialport/parser-delimiter');

const port = new SerialPort('/dev/tty-usbserial1');
const parser = port.pipe(new Delimiter({ delimiter: Buffer.from([0xFF]) })); // Custom binary delimiter

parser.on('data', data => {
  console.log('Received binary data:', data);
});
0

FAQs

Package last updated on 27 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc